home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / uobj.com / TEST.QP < prev    next >
Encoding:
Text File  |  1990-01-10  |  828 b   |  51 lines

  1. program TestClone;  {Quick Pascal Version}
  2.  
  3.   uses CRT,UObj;
  4.  
  5.   type
  6.     Ancestor = object(TObj)
  7.       procedure   WhoAmI;
  8.       end;
  9.  
  10.     procedure   Ancestor.WhoAmI;
  11.       begin
  12.     Writeln('Ancestor');
  13.       end;
  14.  
  15.   type
  16.     Child = object(Ancestor)
  17.       procedure   WhoAmI;     override;
  18.       end;
  19.  
  20.     procedure   Child.WhoAmI;
  21.       begin
  22.     Writeln('Child');
  23.       end;
  24.  
  25.   var
  26.     theAncestor : Ancestor;
  27.     theChild     : Child;
  28.     theClone     : Ancestor;
  29.  
  30.   begin
  31.     ClrScr;
  32.  
  33.     New(theAncestor);
  34.     New(theChild);
  35.  
  36.     theClone := theChild.Clone;
  37.     theChild.WhoAmI;
  38.     theClone.WhoAmI;
  39.     theClone.Free;
  40.  
  41.     writeln;
  42.  
  43.     theClone := theAncestor.Clone;
  44.     theAncestor.WhoAmI;
  45.     theClone.WhoAmI;
  46.     theClone.Free;
  47.  
  48.     theAncestor.Free;
  49.     theChild.Free;
  50.   end.
  51.